package com.itheima.tanhua.web;


import com.itheima.tanhua.pojo.db.UserInfo;
import com.itheima.tanhua.service.UsersService;
import com.itheima.tanhua.vo.UserInfoVo;
import com.itheima.tanhua.vo.UsersCountsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class UsersController {

    @Autowired
    private UsersService usersService;


    //用户资料保存
    @PutMapping
    public ResponseEntity save(UserInfo userInfo){
        usersService.saveUserInfo(userInfo);
        return ResponseEntity.ok(null);
    }


    //互相喜欢，喜欢，粉丝 - 统计
    @GetMapping("/counts")
    public ResponseEntity counts(){
        UsersCountsVo counts = usersService.counts();
        return ResponseEntity.ok(counts);
    }

    //用户资料读取
    @GetMapping
    public ResponseEntity select(Long userId){
        UserInfoVo userInfoVo=usersService.selectUserInfo(userId);
        return ResponseEntity.ok(userInfoVo);
    }
}
